#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int m;
int person;
int student[365];
int cishu=0;
int check;

int checkbirthday()
{
    for (int i=1 ;i<=person ; i++)
    {
        for (int j=i+1 ; j<=person; j++)
        {
            if (student[i]==student[j])
            {
                return 1;
            }
        }
    }
    return 0;
}

void givebirthday()
{
    for (int i=1 ; i<=person ;i++ )
    {
        student[i]=rand()%365+1;
    }
}


int main()
{
  
    cout<<"enter the total number of the class  "<<endl;
    cin>>m;
  
    cout<<"enter the total numnber of student in a class  "<<endl;
    cin>>person;

    srand(time(0));



    for (int i=1 ; i<=m ; i++)
    {
        givebirthday();
        check=checkbirthday();
        if (check==1)
        {
            cishu++;
        }

    }

    float probability;
    probability = (static_cast<long double>(cishu) / m) * 100;

    cout<<"the number of the test is  "<<m<<endl;
    cout<<"the situation appears  "<<cishu<<" times "<<endl;
    cout<<"the final probability is  "<<probability<<" % "<<endl;

}